USE BMIG_Mensual_POST_CADENA
go

IF OBJECT_ID('dbo.WASP_M0016_valores_seguros') IS NOT NULL 
   BEGIN
      DROP PROCEDURE dbo.WASP_M0016_valores_seguros 
      IF OBJECT_ID('dbo.WASP_M0016_valores_seguros') 
      IS
      NOT NULL 
         PRINT 
         '<<< FAILED DROPPING PROCEDURE dbo.WASP_M0016_valores_seguros >>>' 
      ELSE
         PRINT '<<< DROPPED PROCEDURE dbo.WASP_M0016_valores_seguros >>>' 
   END
go

SET ANSI_NULLS ON
go

SET QUOTED_IDENTIFIER ON
go

CREATE PROCEDURE WASP_M0016_valores_seguros 
AS
   BEGIN
      SELECT a.ppsuc,
         a.ppcta,
         a.ppoper,
         a.ppimp11,
         a.ppimp12,
         a.ppimp13,
         a.ppimp14,
         a.ppimp15,
         a.ppimp16,
         a.ppimp17,
         a.ppimp18,
         a.ppimp19 
      INTO dbo.sv_valores_seguros 
      FROM fsd611 AS a (nolock), fsd601 AS b (nolock) 
      WHERE a.pptipo = '' 
      AND a.ppexte = 0 
      AND a.pgcod = b.pgcod 
      AND a.ppmod = b.ppmod 
      AND a.ppsuc = b.ppsuc 
      AND a.ppmda = b.ppmda 
      AND a.ppcta = b.ppcta 
      AND a.ppoper = b.ppoper 
      AND a.ppsbop = b.ppsbop 
      AND a.pptope = b.pptope 
      AND b.d601co = 'S' 
      GROUP BY a.ppsuc, a.ppcta, a.ppoper, a.ppimp11, a.ppimp12, a.ppimp13, a.ppimp14
      , a.ppimp15, a.ppimp16, a.ppimp17, a.ppimp18, a.ppimp19 
   END
go



SET ANSI_NULLS OFF
go

SET QUOTED_IDENTIFIER OFF
go

IF OBJECT_ID('dbo.WASP_M0016_valores_seguros') IS NOT NULL 
   PRINT '<<< CREATED PROCEDURE dbo.WASP_M0016_valores_seguros >>>' 
ELSE
   PRINT '<<< FAILED CREATING PROCEDURE dbo.WASP_M0016_valores_seguros >>>'
go
